package logx

import (
	"time"

	"go.opentelemetry.io/otel/sdk/log"
)

type SamplerConfig struct {
}
type BatcherConfig struct {
	MaxQueueSize       int `json:"max_queue_size" toml:"max_queue_size"`
	ExportTimeout      int `json:"export_timeout" toml:"export_timeout"`
	MaxExportBatchSize int `json:"max_export_batch_size" toml:"max_export_batch_size"`
	ExportInterval     int `json:"export_interval" toml:"export_interval"`
	ExportBufferSize   int `json:"export_buffer_size" toml:"export_buffer_size"`
}

func (c SamplerConfig) NewSampler(exporter log.Exporter) log.Processor {
	return log.NewSimpleProcessor(exporter)
}

func (c BatcherConfig) NewBatcher(exporter log.Exporter) log.Processor {
	opts := []log.BatchProcessorOption{
		log.WithMaxQueueSize(c.MaxQueueSize),
		log.WithExportInterval(time.Duration(c.ExportInterval) * time.Second),
		log.WithExportMaxBatchSize(c.MaxExportBatchSize),
		log.WithExportBufferSize(c.ExportBufferSize),
		log.WithExportTimeout(time.Duration(c.ExportTimeout) * time.Second),
	}

	return log.NewBatchProcessor(exporter,
		opts...,
	)
}
